/*package kss;

import java.io.File;
import java.util.ArrayList;

import kss.WikiDB.PageType;

import org.wikipedia.miner.db.WEnvironment.StatisticName;
import org.wikipedia.miner.model.Article;
import org.wikipedia.miner.model.Category;
import org.wikipedia.miner.model.Page;
import org.wikipedia.miner.model.Redirect;
import org.wikipedia.miner.model.Wikipedia;
import org.wikipedia.miner.util.WikipediaConfiguration;

public class WikiMinerDB extends WikiDB {
	public static Wikipedia wikipedia;
	
	public WikiMinerDB() throws Exception {
		WikipediaConfiguration conf = new WikipediaConfiguration(new File(wikiconfig)) ;
	
	    System.out.println("starting wikipedia DB...");
	    wikipedia = new Wikipedia(conf, false) ;
	    System.out.println("retrieving articles ...");
	}
	
	public void close() { wikipedia.close();}
	
	public long getTotalArticleCount() { return wikipedia.getEnvironment().retrieveStatistic(StatisticName.articleCount);}
	*//**
	 * get the links out (return the Id of links out
	 * 
	 * @param categoryTitle
	 * @param depth
	 * @return
	 *//*
	public ArrayList<Integer> getCategoryLinksOut(String categoryTitle, int depth) {
		Category cat = wikipedia.getCategoryByTitle(categoryTitle);
		if (cat == null) return null;
		ArrayList<Article> dl = CategoryWrapper.getDistinctDescendentArticles(cat, depth);
		if (dl == null || dl.size() == 0) return null;
		
		ArrayList<Integer> ret = new ArrayList<Integer>(dl.size());
		for (int i = 0; i<dl.size(); i++) {
			Article[] al = dl.get(i).getLinksOut();
			if (al == null) continue;
			for (int j = 0; j<al.length; j++) ret.add(al[j].getId());
		}
		return ret;
	}
	
	public int getPageId(String pageTitle, PageType pt) {
		Page p = null;
		if (pt==PageType.ARTICLE) {
			p = wikipedia.getArticleByTitle(pageTitle);
		} else {
			p = wikipedia.getCategoryByTitle(pageTitle);
		}
		if (p== null) return -1;
		return p.getId();
	}
	public ArrayList<Integer> getDistinctDescendentArticles(String categoryTitle, int depth) {
		Category cat = wikipedia.getCategoryByTitle(categoryTitle);
		ArrayList<Article> artList = CategoryWrapper.getDistinctDescendentArticles(cat, depth);
		if (artList == null) return null;
		ArrayList<Integer> ret = new ArrayList<Integer>(artList.size());
		for (int i = 0; i< artList.size();i++) ret.add(artList.get(i).getId());
		return ret;
	}
	public ArrayList<String> getDescendentArticleTitles(String categoryTitle, int depth) {
		Category cat = wikipedia.getCategoryByTitle(categoryTitle);
		ArrayList<Article> artList = CategoryWrapper.getDistinctDescendentArticles(cat, depth);
		if (artList == null) return null;
		ArrayList<String> ret = new ArrayList<String>(artList.size());
		for (int i = 0; i< artList.size();i++) ret.add(artList.get(i).getTitle());
		return ret;
	}
	public ArrayList<String> getDescendentCategoryTitles(String categoryTitle, int depth) {
		Category cat = wikipedia.getCategoryByTitle(categoryTitle);
		ArrayList<Category> catList = CategoryWrapper.getDescendentCategories(cat, depth);
		if (catList == null) return null;
		ArrayList<String> ret = new ArrayList<String>(catList.size());
		for (int i = 0; i< catList.size();i++) ret.add(catList.get(i).getTitle());
		return ret;
	}
	
	
	 * given a title of category and return a list of children articles
	 * @see kss.WikiDB#getChildArticles(java.lang.String)
	 
	public ArrayList<Integer> getChildArticles(String categoryTitle) {
		Category cat = wikipedia.getCategoryByTitle(categoryTitle);
		Article[] al = cat.getChildArticles();
		ArrayList<Integer> ret = new ArrayList<Integer>(al.length);
		for (int i =0; i<al.length; i++) ret.add(al[i].getId());
		return ret;
	}
	public ArrayList<String> getParentCategoryTitles(String pageTitle, PageType pt) {
		Category[] cl= null ;
		if (pt==PageType.ARTICLE) { 
			Article a = wikipedia.getArticleByTitle(pageTitle); 
			if (a != null) cl = a.getParentCategories();
		} 	else {
			Category c = wikipedia.getCategoryByTitle(pageTitle);
			if (c!=null) cl = c.getParentCategories();
		}
		if (cl == null || cl.length == 0) return null;
		ArrayList<String> ret = new ArrayList<String>(cl.length);
		for (int i = 0; i< cl.length; i++) {
			ret.add(cl[i].getTitle());
		}
		return ret;
	}
	public int getTotalLinksInCount(String articleTitle) {
		Article art = wikipedia.getArticleByTitle(articleTitle);
		if (art == null) {return -1;}
		return art.getTotalLinksInCount();
	}
	
	public ArrayList<String> getLinksIn(String articleTitle) {
		Article a = wikipedia.getArticleByTitle(articleTitle);
		if (a == null) return null;
		Article[] al = a.getLinksIn();
		if (al == null || al.length == 0) return null;
		
		ArrayList<String> ret = new ArrayList<String>(al.length);
		for (int i = 0; i<al.length; i++) { ret.add(al[i].getTitle());}
		return ret;
	}
	public ArrayList<Integer> getArticleLinksIn(String articleTitle) {
		Article a = wikipedia.getArticleByTitle(articleTitle);
		if (a == null) return null;
		Article[] al = a.getLinksIn();
		ArrayList<Integer> ret = new ArrayList<Integer>(al.length);
		for (int i = 0; i<al.length; i++) { ret.add(al[i].getId());}
		return ret;
	}
	public ArrayList<Integer> getCategoryLinksIn(String catTitle, int depth) {
		Category cat = wikipedia.getCategoryByTitle(catTitle);
		ArrayList<Article> l = CategoryWrapper.getLinksIn(cat, depth);
		if (l==null) return null;
		ArrayList<Integer> ret = new ArrayList<Integer>();
		for (int i = 0; i<l.size(); i++) { ret.add(l.get(i).getId());}
		return ret;
	}
	public ArrayList<String> getArticleLinksOut(String artTitle, int step) {
		Article art = wikipedia.getArticleByTitle(artTitle);
		ArrayList<String> tl = new ArrayList<String>();
		getLinksOut(art, step, tl);
		return tl;
	}
	void getLinksOut(Article article, int steps, ArrayList<String> links) {
		if (article == null || steps <=0) 	return ;
		Article[] lo = article.getLinksOut();
		if ( lo== null || lo.length == 0)	return ;
		
		for (int i = 0; i < lo.length; i++) {
			Article a = lo[i];
			String at = a.getTitle();
			if (links.contains(at)) continue;
			
			links.add(at);
			getLinksOut(a, steps-1, links);
		}
	}
	
	*//** resolve normalized name if any *//*
	public String getArticleTitleByTitle(String articleTitle) {
		Article a = wikipedia.getArticleByTitle(articleTitle);
		if (a == null) return null;
		return a.getTitle();
	}
	
	public String getArticleById(int id) {
		Page a = wikipedia.getPageById(id);
		if (a == null) return null;
		return a.getTitle();
	}
	public ArrayList<Integer> getRedirects(String articleTitle) {
		Article a = wikipedia.getArticleByTitle(articleTitle);
		Redirect[] directings = a.getRedirects();
		
		if (directings == null) return null;
		ArrayList<Integer>ret = new ArrayList<Integer>();
		for (int k = 0; k< directings.length; k++) {
			ret.add(directings[k].getId());
		}
		return ret;
	}
	public String getFirstParagraphMarkup(String articleTitle) {	
		Article art = wikipedia.getArticleByTitle(articleTitle);
		return art.getFirstParagraphMarkup();
		
	}
}*/